﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
namespace SQT.tracnghiem.Ajax.ASP.News
{
    public partial class edit_News_detail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public static string get_Tag(string s)
        {
            if (s.Trim() != "")
            {
                if (s.IndexOf(',') == -1)
                {
                    var tags = new TblNewsTagController().FetchAll().Where(x => x.TagId == int.Parse(s)).Single();
                    s = tags.TagName;
                }
                else
                {
                    string temp = "";
                    string[] split = new string[s.Split(',').Length];
                    split = s.Split(',');
                    for (int i = 0; i < split.Length; i++)
                    {
                        if (split[i] == "")
                            continue;

                        var tags = new TblNewsTagController().FetchAll().Where(x => x.TagId == int.Parse(split[i])).Single();
                        temp += tags.TagName;
                        if (i < split.Length - 1)
                            temp += ",";
                    }
                    s = temp;
                }
            }
            return s;
        }
    }
}